// 导入axios
import request from '@/utils/request'

// 商品列表数据
export function GetGoodsListPort(data) {
    return request({
        url: '/goods',
        method: 'get',
        params: data
    })
}
// 删除商品列表数据
export function DelGoodsListPort(id) {
    return request({
        url: `/goods/${id}`,
        method: 'delete',

    })
}
// 获取所有商品分类数据
export function cascaderList(data) {
    return request({
        url: `/categories`,
        method: 'get',
        params: data
    })
}
// 获取商品参数列表  categories/:id/attributes/:attrId
export function goodsCan(id, sel) {
    return request({
        url: `/categories/${id}/attributes?sel=${sel}`,
        method: 'get',
    })
}
// 添加动态参数或静态属性接口
export function addAttr(id, attr_name, attr_sel, attr_vals) {
    return request({
        url: `categories/${id}/attributes`,
        method: 'post',
        data: {
            attr_name,
            attr_sel,
            attr_vals
        }
    })
}
// 修改动态参数或静态属性接口
export function editData(id, attrId, attr_name, attr_sel, attr_vals) {
    return request({
        url: `categories/${id}/attributes/${attrId}`,
        method: 'put',
        data: {
            attr_name,
            attr_sel,
            attr_vals
        }
    })
}
// 动态参数静态属性添加子级接口
export function addChild(id, attrId,data) {
    return request({
        url: `categories/${id}/attributes/${attrId}`,
        method: 'put',
        data
    })
}
// 添加商品接口
export function addGoods(data) {
    return request({
        url: '/goods',
        method: 'post',
        data
    })
}
// 添加分类接口
export function addCatePort(data) {
    return request({
        url: '/categories',
        method: 'post',
        data
    })
}
// 编辑分类接口
export function editCatePort(id, data) {
    return request({
        url: `/categories/${id}`,
        method: 'put',
        data
    })
}
// 删除分类接口
export function delCatePort(id) {
    return request({
        url: `/categories/${id}`,
        method: 'delete'
    })
}
// 删除参数/属性接口
export function delParamsPort(cateId,id) {
    return request({
        url: `/categories/${cateId}/attributes/${id}`,
        method: 'delete'
    })
}